import { Controller, Get, Post, Put, Delete, Body, Param, UseGuards, Query } from '@nestjs/common';
import { AskFormService } from '../services/askform.service';
import { AskForm } from '../entities/askform.entity';

@Controller('askforms')
export class AskFormController {
    constructor(private readonly askFormService: AskFormService) {}

    @Get()
    async findAll(): Promise<AskForm[]> {
        return this.askFormService.findAll();
    }

    @Get('my')
    async findMyForms(@Query('userId') userId: string): Promise<AskForm[]> {
        return this.askFormService.findByUserId(userId);
    }

    @Get('unanswered')
    async findUnansweredForms(): Promise<AskForm[]> {
        return this.askFormService.findUnansweredForms();
    }

    @Get(':id')
    async findOne(@Param('id') id: number): Promise<AskForm> {
        return this.askFormService.findOne(id);
    }

    @Post()
    async create(@Body() askForm: AskForm): Promise<AskForm> {
        return this.askFormService.create(askForm);
    }

    @Put(':id')
    async update(@Param('id') id: number, @Body() askForm: AskForm): Promise<AskForm> {
        return this.askFormService.update(id, askForm);
    }

    @Delete(':id')
    async remove(@Param('id') id: number): Promise<void> {
        return this.askFormService.remove(id);
    }
} 